﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using COFE.Core.Filter;

namespace COFE.Core.EntryType
{
    public class EntryTypeFilterGenerator : IEntryFilterGenerator
    {
        #region Constructor

        #endregion

        #region Methods

        public IEntryFilter[] GenerateFilters(IFileSystemInfo entry)
        {
            List<IEntryFilter> retVal = new List<IEntryFilter>();

            if (entry is IDirectoryInfo)
                if ((entry as IDirectoryInfo).InternalProperties.IsFileBasedFS)
                    entry = (entry as IDirectoryInfo).InternalProperties.FileBasedFSFile;

            if (entry is IDirectoryInfo)            
                retVal.Add(new FileTypeEntryFilter("folder"));
            else
            {
                string ext = COFEPath.GetExtension(entry.Name);
                retVal.Add(new FileTypeEntryFilter(ext));
            }

            return retVal.ToArray();
        }

        #endregion

        #region Data

        #endregion

        #region Public Properties

        #endregion
    }
}
